BeSly Software Solutions About yab Demos About us Admin






Name:

for -- starts a for-loop

Synopsis:
 
for a=1 to 100 step 2 
  ... 
next a 

Description:
The for-loop lets its numerical variable (a in the synopsis) assume all valueswithin the given range. The optional step-clause may specify a value (default: 1) by which the variable will be incremented (or decremented, if step is negative).

Any for-statement can be replaced by a set of ifs and gotos; as you may infer from the example below this is normally not feasable. However if you want to know in detail how the for-statement works, you should study this example, which presents a for-statement and an exactly equivilant series of ifs and gotos.

Example:
for a=1 to 10 step 2
	print a
next a

a=1 
label check 
if (a>10) goto done 
print a 
a=a+2 
goto check 
label done 
Explanation:

This example simply prints the numbers 1, 3, 5, 7 and 9. It does this twice: 
First with a simple for-statment and then with ifs and gotos.



Related: step, next